package com.mall.order.biz.factory;

import com.mall.order.biz.context.CreateOrderContext;
import com.mall.order.biz.context.TransHandlerContext;
import com.mall.order.biz.convert.CreateOrderConvert;
import com.mall.order.biz.convert.TransConvert;
import com.mall.order.biz.handler.*;
import com.mall.order.dto.CreateSeckillOrderRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class PromoOrderProcessPipelineFactory extends AbstranctTransPipelineFactory<CreateSeckillOrderRequest>{

    @Autowired
    private ValidateHandler validateHandler;
    @Autowired
    private InitOrderHandler initOrderHandler;
    @Autowired
    LogisticalHandler logisticalHandler;




    @Override
    protected TransHandlerContext createContext() {
        CreateOrderContext createOrderContext = new CreateOrderContext();
        return createOrderContext;
    }

    @Override
    protected void doBuild(TransPipeline pipeline) {
        pipeline.addLast(validateHandler);
        pipeline.addLast(initOrderHandler);
        pipeline.addLast(logisticalHandler);
    }

    @Override
    protected TransConvert createConvert() {
        return new CreateOrderConvert();
    }
}
